#include "util.h"
#include <stddef.h>

void pushCallchain(CALL_CHAIN_S *head, CALL_CHAIN_S *node)
{
    CALL_CHAIN_S *temp = NULL;
    temp = head;

    while(1) {
        if(temp->next == NULL) {
            temp->next = node;
            break;
        } else {
            temp = temp->next;
        }
    }
}

CALL_CHAIN_S * popCallchain(CALL_CHAIN_S *head)
{
    CALL_CHAIN_S *temp = NULL;
    CALL_CHAIN_S *next = NULL;
    temp = head;
    next = temp->next;

    if(next == NULL)
        return NULL;

    while(1) {
        if(next->next == NULL) {
            temp->next = NULL;
            break;
        } else {
            temp = temp->next;
            next = next->next;
        }
    }
    return next;
}